import request from '@/utils/request'

// api地址
const api = {
  userInfo: 'user/info',
  assets: 'user/assets',
  bindMobile: 'user/bindMobile',
  personal: 'user/personal',
  directUsers: 'user/directUsers',
  getSonUsers: 'user/getSonUsers',
  regionTree: 'region/tree',
  getMerchantApply: 'user/merchantApply',
  userWithdraw: 'user/withdraw',
  wechatGetSignInfo: 'wechat/getWechatShareConfig', // 微信jssdk凭证获取
  getAccountList: 'user/getAccountList', // 获取关联的账号列表
  bindAccount: 'user/bindAccount', // 绑定其他账号到当前账号（openId)
  switchAccountLogin: 'user/switchAccountLogin' ,// 切换账号登陆
  transferBalance:'user/transferBalance',
  editMobileAndPwd: 'passport/editMobileAndPwd' // 修改手机号和密码
}

// 当前登录的用户信息
export const info = (param, option) => {
  const options = {
    isPrompt: true, //（默认 true 说明：本接口抛出的错误是否提示）
    load: true, //（默认 true 说明：本接口是否提示加载动画）
    ...option
  }
  return request.get(api.userInfo, param, options)
}

// 账户资产
export const assets = (param, option) => {
  return request.get(api.assets, param, option)
}

// 绑定手机号
export const bindMobile = (data, option) => {
  return request.post(api.bindMobile, data, option)
}

// 修改个人信息（头像昵称）
export const personal = (data, option) => {
  return request.post(api.personal, data, option)
}

// 查询用户的直推用户
export const directUsers = (params, option) => {
  return request.get(api.directUsers, params, option)
}

// 查询下层用户
export const getSonUsers = (params, option) => {
  return request.get(api.getSonUsers, params, option)
}

// 获取所有地区
export const regionTree = (params, option) => {
  return request.get(api.regionTree, params, option)
}

// 申请成为商家
export const getMerchantApply = (data, option) => {
  return request.post(api.getMerchantApply, data, option)
}

// 发起提现申请
export const userWithdraw = (data, option) => {
  return request.post(api.userWithdraw, data, option)
}

// 微信jssdk凭证获取
export const wechatGetSignInfo = (params, option) => {
  return request.get(api.wechatGetSignInfo, params, option)
}

// 获取关联的账号列表
export const getAccountList = (params, option) => {
  return request.get(api.getAccountList, params, option)
}

// 绑定其他账号到当前账号（openId)
export const bindAccount = (data, option) => {
  return request.post(api.bindAccount, data, option)
}

// 切换账号登陆
export const switchAccountLogin = (params, option) => {
  return request.get(api.switchAccountLogin, params, option)
}

// 余额转账
export const transferBalance = (data, option) => {
  return request.post(api.transferBalance, data, option)
}

// 修改手机号和密码
export const editMobileAndPwd = (data, option) => {
  return request.post(api.editMobileAndPwd, data, option)
}
